home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / xman / help.c < prev    next >
C/C++ Source or Header  |  1994-09-27  |  3KB  |  99 lines

  1. /*
  2.  * xman - X window system manual page display program.
  3.  *
  4.  * $XConsortium: help.c,v 1.9 91/07/01 14:05:09 dave Exp $
  5.  *
  6.  * Copyright 1987, 1988 Massachusetts Institute of Technology
  7.  *
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted, provided
  10.  * that the above copyright notice appear in all copies and that both that
  11.  * copyright notice and this permission notice appear in supporting
  12.  * documentation, and that the name of M.I.T. not be used in advertising or
  13.  * publicity pertaining to distribution of the software without specific,
  14.  * written prior permission.  M.I.T. makes no representations about the
  15.  * suitability of this software for any purpose.  It is provided "as is"
  16.  * without express or implied warranty.
  17.  *
  18.  * Author:    Chris D. Peterson, MIT Project Athena
  19.  * Created:   January 19, 1988
  20.  */
  21.  
  22. #include "globals.h"
  23.  
  24. static Atom wm_delete_window;
  25.  
  26. ManpageGlobals * InitPsuedoGlobals();
  27.  
  28. /*    Function Name: MakeHelpWidget.
  29.  *    Description: This function creates the help widget so that it will be
  30.  *                   ready to be displayed.
  31.  *    Arguments: none.
  32.  *    Returns: none.
  33.  */
  34.  
  35. Boolean
  36. MakeHelpWidget()
  37. {
  38.  
  39.   ManpageGlobals * man_globals;    /* The psuedo global structure. */
  40.   
  41.   if (help_widget != NULL)    /* If we already have a help widget. 
  42.                    then do not create one. */
  43.     return(TRUE);
  44.  
  45.   man_globals = InitPsuedoGlobals();
  46.  
  47.   CreateManpageWidget(man_globals, HELPNAME, FALSE);
  48.   help_widget = man_globals->This_Manpage;
  49.  
  50.   if (OpenHelpfile(man_globals) == FALSE) {
  51.     XtDestroyWidget(help_widget);
  52.     help_widget = NULL;
  53.     return(FALSE);
  54.   }
  55.  
  56.   ChangeLabel(man_globals->label, "Xman Help");
  57.  
  58.   XtManageChild( man_globals->manpagewidgets.manpage );
  59.   XtRealizeWidget(  help_widget );
  60.   SaveGlobals( man_globals->This_Manpage, man_globals );
  61.   AddCursor( help_widget, resources.cursors.manpage);
  62.  
  63. /*
  64.  * Set up ICCCM delete window.
  65.  */
  66.   wm_delete_window = XInternAtom(XtDisplay(help_widget), "WM_DELETE_WINDOW",
  67.                  False);
  68.   XtOverrideTranslations
  69.       (man_globals->This_Manpage, 
  70.        XtParseTranslationTable ("<Message>WM_PROTOCOLS: RemoveThisManpage()"));
  71.   (void) XSetWMProtocols (XtDisplay(man_globals->This_Manpage),
  72.               XtWindow(man_globals->This_Manpage),
  73.               &wm_delete_window, 1);
  74.  
  75.   return(TRUE);
  76. }
  77.  
  78. /*    Function Name: OpenHelpfile
  79.  *    Description: opens the helpfile.
  80.  *    Arguments: man_globals - the psuedo globals structure.
  81.  *    Returns: False if no helpfile was found.
  82.  */
  83.  
  84. Boolean
  85. OpenHelpfile(man_globals)
  86. ManpageGlobals * man_globals;
  87. {
  88.   FILE * help_file_ptr;
  89.  
  90.   if( (help_file_ptr = fopen(resources.help_file, "r")) == NULL ) {
  91.     PopupWarning(man_globals,
  92.          "Could not open help file, NO HELP WILL BE AVALIABLE.");
  93.     return(FALSE);
  94.   }
  95.     
  96.   OpenFile(man_globals, help_file_ptr);
  97.   return(TRUE);
  98. }
  99.